package com.wl.service.impl;

import com.wl.dao.PersonDAO;
import com.wl.entity.Person;
import com.wl.model.User;
import com.wl.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private PersonDAO personDAO;

    public User getUserById(String id) {
        return new User("1","jacky");
    }

    public Person getPerson(Integer id){
        return personDAO.getById(id);
    }

    @Transactional
    public int updatePersonById(Integer id, String name) {
        int count = personDAO.updatePersonById(id, name);
//        throw new NullPointerException(); // 跑异常，将回滚
        return count;
    }

}
